package org.usmile.algorithms.huawei.acm;

import java.util.*;

// https://blog.csdn.net/amos_cloud/article/details/129350029
public class _寻找相似单词 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int wordsNum = sc.nextInt();
        sc.nextLine();
        Map<String, String> wordMap = new HashMap<>();
        for (int i = 0; i < wordsNum; i++) {
            String word = sc.nextLine();
            char[] chars = word.toCharArray();
            Arrays.sort(chars);
            wordMap.put(word, new String(chars));
        }

        String word = new String(sc.nextLine().toCharArray());
        List<String> matched = new ArrayList<>();
        for (Map.Entry<String, String> entry : wordMap.entrySet()) {
            if (entry.getValue().equals(word)) {
                matched.add(entry.getKey());
            }
        }

        if (matched.size() == 0) {
            System.out.println("null");
        }
        matched.sort(String::compareTo);

        System.out.println(String.join(" ", matched));
    }
}
